package com.lzy.system.business.common;

import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;

import java.util.Arrays;
import java.util.List;

/**
 * description:存储模型公共配置<br>
 * date: 2024-8-2 0:54 <br>
 * author: lcc <br>
 * version: 1.0 <br>
 */
public class SysBusEntityCommon {
    public static List<String> exclude = Arrays.asList("id", "create_time", "update_time", "create_user_id", "update_user_id");

    public static String getSqlTemplate(Context context, String db, String dir) {
        //生产添加语句
        //模板引擎
        TemplateEngine engine = new TemplateEngine();
        //读取磁盘中的模板文件
        ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
        //路径
        resolver.setPrefix("thymeleaf/");
        //后缀
        resolver.setSuffix(".sql");
        //设置模板模式、默认是HTML
        resolver.setTemplateMode("TEXT");
        //设置引擎使用 resolve
        engine.setTemplateResolver(resolver);
        //准备数据 使用context
        String out = engine.process(dir + "/" + db, context);
        return out;
    }
}
